import CommonHeader from '@/components/common-header/index'
import CommonInfo from '../components/CommonInfo/index'
import ApprovalButton from '../components/Button/index'
import SelectList from '../components/SelectList/index'
import Textarea from '../components/Textarea/index'
import DateSelect from '../components/DateSelect/index'
export default {
  name: 'LeaveApproval',
  components: {
    CommonHeader,
    CommonInfo,
    ApprovalButton,
    SelectList,
    Textarea,
    DateSelect,
  },
  data() {
    return {
      warn: '您有未填写的数据',
      approval: {
        leaveType: '',
        leaveReason: '',
        leaveStartTime: '',
        leaveOverTime: '',
      },
      leaveTypeList: ['事假', '病假', '调休', '年假', '产假'],
    }
  },
  methods: {
    getLeaveType(data) {
      this.approval.leaveType = data
    },
    getLeaveReason(data) {
      this.approval.leaveReason = data.mp.detail.__args__[0]
    },
    getLeaveStartTime(data) {
      this.approval.leaveStartTime = data
    },
    getLeaveOverTime(data) {
      this.approval.leaveOverTime = data
    },
  },
  watch: {
    approval: {
      deep: true,
      handler: function(newV, oldV) {
        for (let key in newV) {
          if (!newV[key]) {
            return
          }
        }
        this.warn = ''
      },
    },
  },
}
